import matplotlib.pyplot as plt
import random

x = range(60)
y_beijing = [random.uniform(10, 15) for i in x]
y_shanghai = [random.uniform(15, 25) for i in x]

plt.figure(figsize=(20, 8), dpi=100)

plt.plot(x, y_beijing, label="beijing", color="g", linestyle="-.")
plt.plot(x, y_shanghai, label="shanghai")

y_ticks = range(40)
plt.yticks(y_ticks[::5])

x_ticks_label = [f"11点{i}分" for i in x]
plt.xticks(x[::5], x_ticks_label[::5])

plt.grid(True, linestyle="--", alpha=0.6)

plt.xlabel("时间")
plt.ylabel("温度")
plt.title("一小时温度变化图", fontsize=20)

plt.legend(loc=3)

plt.savefig('temperature.png')
plt.show()
